from django.db import models
from datetime import datetime
# Create your models here.
from django.contrib.auth.models import AbstractUser
class UserProfile(AbstractUser):
    nickname = models.CharField(max_length=50,verbose_name='昵称',default='')
    brithday = models.DateField(verbose_name="生日",null=True,blank=True)
    gender = models.CharField(choices=(('male',u'男'),('female',u'女')),default='male',max_length=20,verbose_name='性别')
    address = models.CharField(max_length=200,default=u'',verbose_name='地址')
    mobile = models.CharField(max_length=11,null=True,blank=True,verbose_name='手机号')
    image = models.ImageField(upload_to='image/%Y/%m',default=u'image/default.png',max_length=200,verbose_name='头像')
    class Meta:
        verbose_name = "用户信息"
        verbose_name_plural = verbose_name
    def __unicode__(self):
        return self.username
class EmailVerifyRecord(models.Model):
    code = models.CharField(max_length=20,verbose_name='验证码')
    email = models.EmailField(max_length=50,verbose_name='邮箱')
    send_type = models.CharField(choices=(('register',u'注册'),('forget',u'找回密码')),max_length=10,verbose_name='验证码类型')
    send_time = models.DateTimeField(default=datetime.now,verbose_name='发送时间')
    class Meta:
        verbose_name = u'邮箱验证码'
        verbose_name_plural = verbose_name
class Banner(models.Model):
    title = models.CharField(max_length=100,verbose_name='标题')
    image = models.ImageField(upload_to='banner/%Y/%m',verbose_name='轮播图',max_length=200)
    url = models.URLField(max_length=200,verbose_name='访问地址')
    index = models.IntegerField(default=100,verbose_name='顺序')
    add_time = models.DateTimeField(default=datetime.now,verbose_name='添加时间')
    class Meta:
        verbose_name = '轮播图'
        verbose_name_plural = verbose_name